import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
import store from "../store"
// 1. 定义路由组件， 注意，这里一定要使用 文件的全名（包含文件后缀名）
// 2. 定义路由配置
const routes = [{
    /* 首页 */
    path: "/",
    name: 'Home',
    meta: {
      title: '首页'
    },
    component: () => import("../view/home/Home.vue")
  },
  /* 最新资讯 */
  {
    path: "/newsInfomation/:province?/:city?",
    name: 'newsInfomation',
    meta: {
      title: '最新资讯查询页'
    },
    component: () => import("../view/newsInfomation/Index.vue")
  },
  /* 政策通知 */
  {
    path: "/policyNotice",
    name: 'policyNotice',
    meta: {
      title: '政策通知查询页'
    },
    component: () => import("../view/policyInformation/policyNotice.vue")
  },
  /* 政策通知详情 */
  {
    path: "/inform/:id",
    name: 'inform',
    meta: {
      title: '政策通知详情页'
    },
    component: () => import("../view/inform/index.vue")
  },
  /* 政策通知部门内页 */
  {
    path: "/departmentInside",
    name: 'departmentInside',
    meta: {
      title: '政策通知部门内页'
    },
    component: () => import("../view/policyInformation/departmentInside.vue")
  },
  /* 政策图谱 */
  {
    path: "/policyMap",
    name: 'policyMap',
    meta: {
      title: '政策图谱页面'
    },
    component: () => import("../view/policyInformation/policyMap.vue")
  },
  /* 政策解读 */
  {
    path: "/governmentUnscramble/:province?/:city?",
    name: "governmentUnscramble",
    meta: {
      title: '政策解读查询页面'
    },
    component: () => import("../view/governmentUnscramble/index.vue")
  },
  /* 政策解读详情 */
  {
    path: '/gUDetails',
    name: "gUDetails",
    meta: {
      title: '政策解读详情页面'
    },
    component: () => import("../view/governmentUnscramble/gUDetails.vue")
  },
  /* 政策订阅 */
  {
    path: "/subscriptionpage",
    name: "subscriptionpage",
    meta: {
      title: '政策订阅页面'
    },
    component: () => import("../view/governmentUnscramble/subscription.vue")
  },
  // 企业认领
  {
    path: "/enterpriseClaim",
    name: "enterpriseClaim",
    meta: {
      title: '企业认领页面'
    },
    component: () => import("../view/EnterpriseClaim/enterpriseClaim.vue")
  },
  /* 企业对比(选择企业) */
  {
    path: "/condition",
    name: "condition",
    meta: {
      title: '企业对比(选择企业)页面'
    },
    component: () => import("../view/EnterpriseComparison/condition.vue")
  },
  /* 企业对比(对比详情) */
  {
    path: "/comparisonDetails",
    name: "comparisonDetails",
    meta: {
      title: '企业对比(对比详情)页面'
    },
    component: () => import("../view/EnterpriseComparison/comparisonDetails.vue")
  },
  /* 企业对比(c查企业) */
  {
    path: "/enterprise",
    // name: "enterprise",
    component: () => import("../view/Enterprise/index.vue"),
    redirect: "/enterprise/honor",
    children: [{
      /* 查看荣誉 */
      path: "/enterprise/honor",
      name: "honor",
      meta: {
        title: '查看荣誉页面'
      },
      component: () => import("../view/Enterprise/honor.vue")
    }, {
      /* 查看专利 */
      path: "/enterprise/patent",
      name: "patent",
      meta: {
        title: '查看专利页面'
      },
      component: () => import("../view/Enterprise/patent.vue")
    }, {
      /* 查看商标 */
      path: "/enterprise/brand",
      name: "brand",
      meta: {
        title: '查看商标页面'
      },
      component: () => import("../view/Enterprise/brand.vue")
    }, {
      /* 查看软著 */
      path: "/enterprise/soft",
      name: "soft",
      meta: {
        title: '查看软著页面'
      },
      component: () => import("../view/Enterprise/soft.vue")
    }]
  },
  /* 会员中心模块 */
  {
    path: "/VIP",
    name: "VIP",
    component: () => import("../view/VIP/userInfo/index.vue"),
    redirect: "/VIP/userInfo",
    children: [{
      /* 浏览历史 */
      path: "/VIP/viewHistory",
      name: "viewHistory",
      meta: {
        title: '浏览历史'
      },
      component: () => import("../view/VIP/userInfo/viewHistory.vue")
    }, {
      /* 个人中心 */
      path: "/VIP/userInfo",
      name: "userInfo",
      meta: {
        title: '个人中心页面'
      },
      component: () => import("../view/VIP/userInfo/userInfocentent.vue")
    }, {
      /* 我的消息 */
      path: "/VIP/information",
      name: "information",
      meta: {
        title: '我的消息页面'
      },
      component: () => import("../view/VIP/userInfo/information.vue")

    }, {
      /* 我的关注 */
      path: "/VIP/attention",
      name: "attention",
      meta: {
        title: ''
      },
      component: () => import("../view/VIP/userInfo/attention.vue"),
      redirect: "/VIP/attention/enterprise",
      children: [{
        path: "/VIP/attention/enterprise",
        name: "myEnterprise",
        meta: {
          title: '我关注的企业页面'
        },
        component: () => import("../components/VIP/enterprise.vue")
      }, {
        path: "/VIP/attention/department",
        name: "department",
        meta: {
          title: '我关注的部门页面'
        },
        component: () => import("../components/VIP/department.vue")
      }]
    }, { // 我的企业
      path: "/VIP/company",
      name: "company",
      meta: {
        title: '我的企业页面'
      },
      component: () => import("../view/VIP/userInfo/company.vue")
    }, {
      /* 我的订单 */
      path: "/VIP/order",
      name: "order",
      meta: {
        title: '我的订单页面'
      },
      component: () => import("../view/VIP/userInfo/order.vue")
    }, {
      /* 谁看了我 */
      path: "/VIP/discover",
      name: "discover",
      meta: {
        title: '谁看了我页面'
      },
      component: () => import("../view/VIP/userInfo/discover.vue")

    }, {
      /* 分享统计 */
      path: "/VIP/statistics",
      name: "statistics",
      meta: {
        title: ''
      },
      component: () => import("../view/VIP/userInfo/statistics.vue"),
    }, {
      path: "/VIP/statistics_setails",
      name: "statistics_setails",
      meta: {
        title: '我的分享阅读信息列表页'
      },
      component: () => import("../view/VIP/userInfo/statistics_details.vue")
    }, {
      // 谁看了我的内页
      path: "/VIP/discover/discover_details",
      name: "discover/discover_details",
      meta: {
        title: '谁看了我内页'
      },
      component: () => import("../view/VIP/userInfo/discover_details.vue")
    }, {
      // 审核列表
      path: "/VIP/toExamine",
      name: "toExamine",
      component: () => import("../view/VIP/userInfo/toExamine.vue"),
      redirect: "/VIP/toExamine/enterpriseAuditForm",
      children: [{
        path: "/VIP/toExamine/enterpriseAuditForm",
        name: "enterpriseAuditForm",
        meta: {
          title: '审核列表页面'
        },
        component: () => import("../view/VIP/userInfo/enterpriseAuditForm.vue")
      }]
    }]
  }, {
    /* 测试页 */
    path: "/test",
    mame: "test",
    component: () => import("../view/test/index.vue")
  }, {
    // 活动详情
    path: '/festival',
    name: 'festival',
    meta: {
      title: '活动详情'
    },
    component: () => import('../view/festival/Index.vue')
  },
  /* 项目查询 */
  {
    path: "/projectQuery",
    name: "projectQuery",
    meta: {
      title: '项目查询页面'
    },
    component: () => import("../view/Project/projectQuery.vue")
  },
  /* 项目地图 */
  {
    path: "/projectMap",
    name: "projectMap",
    meta: {
      title: '项目地图页面'
    },
    component: () => import("../view/Project/projectMap.vue")
  }, {
    // 注册
    path: "/register",
    name: "register",
    meta: {
      title: '注册页面'
    },
    component: () => import("../view/VIP/register.vue")
  }, {
    // 注册
    path: "/blankPage",
    name: "blankPage",
    meta: {
      title: ''
    },
    component: () => import("../view/VIP/blankPage.vue")
  },
  {
    // 忘记密码
    path: "/forget",
    name: "forget",
    meta: {
      title: '忘记密码页'
    },
    component: () => import("../view/VIP/forget.vue")
  },
  /* 园区中心 */
  {
    path: "/ParkCenter",
    name: "ParkCenter",
    meta: {
      title: '园区中心页'
    },
    component: () => import("../view/park/ParkCenter.vue")
  },
  /* 园区中心详情*/
  {
    path: "/ParkCenter_details",
    name: "ParkCenter_details",
    meta: {
      title: '园区中心详情'
    },
    component: () => import("../view/park/ParkCenter_details.vue")
  }, {
    // 登录
    path: "/login",
    name: "login",
    meta: {
      title: '登录页面'
    },
    component: () => import("../view/VIP/login.vue")
  }, {
    // 搜索页面
    path: "/search",
    name: "search",
    meta: {
      title: '搜索页面'
    },
    component: () => import("../view/search/index.vue")
  },
  {
    // 搜索页面
    path: "/aboutUs",
    name: "aboutUs",
    meta: {
      title: '关于我们页面'
    },
    component: () => import("../view/footer/aboutUs.vue")
  },
  {
    // 调转到荣誉内页
    path: "/policyPage",
    name: "policyPage",
    meta: {
      title: '荣誉内页'
    },
    component: () => import("../view/governmentUnscramble/policyPage.vue")
  },
  /* 服务商页 */
  {
    path: "/service",
    name: "services",
    meta: {
      title: '服务商页'
    },
    component: () => import("../view/serve/serveDedils.vue")
  },
  /* 服务商详情页 */
  {
    path: "/dedils",
    name: "dedils",
    meta: {
      title: '服务商详情页'
    },
    component: () => import("../view/serve/dedils.vue")
  }, /* 会员页 */ {
    path: "/pageVIP",
    name: "pageVIP",
    meta: {
      title: '会员页'
    },
    component: () => import("../view/VIP/pageVIP.vue")
  }, {
    // 功能介绍
    path: "/introduce",
    name: "introduce",
    meta: {
      title: '功能介绍页'
    },
    component: () => import("../view/footer/introduce.vue")
  }, {
    // 附近企业
    path: "/nearbyEnterprise",
    name: "nearbyEnterprise",
    meta: {
      title: '附近企业页'
    },
    component: () => import("../view/Enterprise/nearbyEnterprise.vue")
  }, {
    // 最新资讯
    path: "/newInform",
    name: "newInform",
    meta: {
      title: '附近企业页'
    },
    component: () => import("../view/inform/newInform.vue")
  }, {
    // 绑定手机号
    path: '/bindPhoneNumber',
    name: 'bindPhoneNumber',
    meta: {
      title: '绑定手机号'
    },
    component: () => import('../view/VIP/bindPhoneNumber.vue')
  }
];


// 3. 创建路由实例
const router = new VueRouter({
  routes
})


router.beforeEach((to, from, next) => {
  console.log("跳转到页面-->", to.meta.title)
  // console.log("toName", to.name)
  // console.log("from", from.name)
  if (to.name == 'login') {
    store.commit("setBackName", from.name)
  }
  if (window._hmt) {
    if (to.path) {
      window._hmt.push(['_trackPageview', '/#' + to.fullPath])
    }
  }
  // 回到顶部
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0

  next()
})


export default router
